<?php

namespace app\common\validate;

use think\Validate;

class GoodsValidate extends Validate
{
	
	/**
	 * 验证规则
	 * @var [array]
	 */
	protected $rule = [
        'gid|商品id' => 'require',
        'name|商品名' => 'require',
        'price|价格' => 'require',
        'discount_price|折扣价格' => 'require',
        'stock|库存量' => 'require',
        'cover_img|封面图' => 'require',
        'description|描述' => 'require',
        'category_id|分类id' => 'require',
        'type|类型' => 'require',
        'msg' => 'require',
        'keyword|搜索关键字' => 'require'
    ];

    /**
     * 添加
     * @Author   Yichen
     * @DateTime 2020-05-02T17:06:27+0800
     * @return   [type]                   [description]
     */
    public function sceneAdd()
    {
    	return $this->only(['name', 'price', 'cover_img', 'description', 'category_id']);
    }

    /**
     * 查询详情
     * @Author   Yichen
     * @DateTime 2020-05-02T17:22:33+0800
     * @return   [type]                   [description]
     */
    public function sceneQuery()
    {
        return $this->only(['gid']);
    }

    /**
     * 添加详情
     * @Author   Yichen
     * @DateTime 2020-05-03T10:29:05+0800
     * @return   [type]                   [description]
     */
    public function sceneAddProperty()
    {
        return $this->only(['gid', 'specifications_name', 'price', 'big_images', 'stock']);
    }

    /**
     * 完成
     * @Author   Yichen
     * @DateTime 2020-05-03T10:30:02+0800
     * @return   [type]                   [description]
     */
    public function sceneFinish()
    {
        return $this->only(['gid', 'type']);
    }

    /**
     * 上架或下架
     * @Author   Yichen
     * @DateTime 2020-05-04T14:01:57+0800
     * @return   [type]                   [description]
     */
    public function sceneProOrEna()
    {
        return $this->only(['msg', 'gid']);
    }

    /**
     * 删除
     * @Author   Yichen
     * @DateTime 2020-05-04T14:04:43+0800
     * @return   [type]                   [description]
     */
    public function sceneDel()
    {
        return $this->only(['gid']);
    }

    /**
     * 前台搜索
     * @Author   Yichen
     * @DateTime 2020-05-04T20:29:57+0800
     * @return   [type]                   [description]
     */
    public function sceneIndexSearch()
    {
        return $this->only(['keyword']);
    }
}